package com.example.wangfanwangluo.wangfanboss;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.TextView;
import com.example.wangfanwangluo.wangfanboss.Adapters.GenzongAdapter;
import com.example.wangfanwangluo.wangfanboss.Models.GenzongModel;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by wangfanwangluo on 2017/11/28.
 */

public class FragmentGenzongDetail extends Fragment {

    //定义跟踪fragment，使与gengzongdetail.xml相对应
    private DocumentDetail orderInfo;
    private ListView ordertrack_listview;
    private List<GenzongModel> trackInfoList = new ArrayList<GenzongModel>();
    private GenzongAdapter trackInfoAdapter;
    private View vHead;
    private String oid; //获取运单详情id值
    private TextView ordertrack_head_ordersn; //运单号
    private TextView ordertrack_head_orderstate; //运单状态
    private TextView ordertrack_head_start; //起始地
    private TextView ordertrack_head_end;   //终止地
    private TextView ordertrack_head_nametime;  //名字+时间
    private TextView ordertrack_head_company; //公司名称

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        //定义跟踪fragment，使与gengzongdetail.xml相对应
        return inflater.inflate(R.layout.fragment_genzongdetail, container, false);
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initView();
    }
     //初始化界面
    private void initView(){
        orderInfo = (DocumentDetail) getActivity(); //获取主activity
        //获取运单详情id值
        Bundle bundle = orderInfo.getIntent().getExtras();
        oid = bundle.getString("oid");
        ordertrack_listview = (ListView) orderInfo.findViewById(R.id.listview_genzongdetail);
        vHead = View.inflate(orderInfo, R.layout.headerview_genzongdetial, null);
        ordertrack_head_ordersn = (TextView) vHead.findViewById(R.id.ordertrack_head_ordersn);
        ordertrack_head_orderstate = (TextView) vHead.findViewById(R.id.ordertrack_head_orderstate);
        ordertrack_head_start = (TextView) vHead.findViewById(R.id.ordertrack_head_start);
        ordertrack_head_end = (TextView) vHead.findViewById(R.id.ordertrack_head_end);
        ordertrack_head_nametime = (TextView) vHead.findViewById(R.id.ordertrack_head_nametime);
        ordertrack_head_company = (TextView) vHead.findViewById(R.id.ordertrack_head_company);

        ordertrack_listview.addHeaderView(vHead); //给listview添加header
        trackInfoAdapter = new GenzongAdapter(orderInfo, R.layout.genzongitem, trackInfoList);
//        getOrderTrack(); //请求网络数据
    }

    //重新登录
//    private void goLogin(){
//        Intent intent = new Intent(orderInfo, Login.class);
//        startActivity(intent);
//        orderInfo.overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
//        orderInfo.finish();
//    }


}
